
/**更换树的图标*/
//tree node click
//id:展开节点的容器id  必须
//actionId:树Vc的行为id 必须
//extendNodeId和levelDown为可选参数,但必须同时出现,否则不生效
var tk = function(id,actionid,extendNodeId,extendClick,levelDown) {
	if(id.split(",").length>4 && $(id.substring(0,id.lastIndexOf(","))+",e")){
		if($(id.substring(0,id.lastIndexOf(","))+",e").style.visibility=="hidden"){
			if(isHave(id.substring(0,id.lastIndexOf(",")))){
				showChild(id.substring(0,id.lastIndexOf(",")));
			}else{
				$(id.substring(0,id.lastIndexOf(","))+",cset").style.display = "block";
				if(extendNodeId && levelDown){
					loadTree(id.substring(0,id.lastIndexOf(","))+",cset",
					          actionid.substring(4,actionid.length),
					          "nodeId,"+id.substring(0,id.lastIndexOf(",")).replace(/,/g,"#")+"",
					          extendNodeId,extendClick,levelDown);
				}else{
					loadTree(id.substring(0,id.lastIndexOf(","))+",cset",
					          actionid.substring(4,actionid.length),
					          "nodeId,"+id.substring(0,id.lastIndexOf(",")).replace(/,/g,"#")+""); 
				}       
			}
			//节点图片更换
			ctp(id.substring(0,id.lastIndexOf(",")) + "icon,u");
			$(id.substring(0,id.lastIndexOf(",")) + ",e").style.visibility = "inherit";
			$(id.substring(0,id.lastIndexOf(",")) + ",c").style.visibility = "hidden";
		} else {
			hiddenChild(id.substring(0,id.lastIndexOf(",")));
			ctp(id.substring(0,id.lastIndexOf(",")) + "icon,s");
			$(id.substring(0,id.lastIndexOf(",")) + ",c").style.visibility = "inherit";
			$(id.substring(0,id.lastIndexOf(",")) + ",e").style.visibility = "hidden";
		}
		treeLayOut(id.split(",")[0]+",-1");
	}
	if(event){
		event.cancelBubble = true;
	}
	
};
//根节点无加号click
var tkr = function(id,actionid,extendNodeId,extendClick,levelDown) {
	if(id.split(",").length>4){
	   if($(id.substring(0,id.lastIndexOf(","))+"icon,s")){
			if($(id.substring(0,id.lastIndexOf(","))+"icon,s").style.visibility=="hidden"){
				if(isHave(id.substring(0,id.lastIndexOf(",")))){
					showChild(id.substring(0,id.lastIndexOf(",")));
				}else{
					$(id.substring(0,id.lastIndexOf(","))+",cset").style.display = "block";
					if(extendNodeId && levelDown){
						loadTree(id.substring(0,id.lastIndexOf(","))+",cset",
						          actionid.substring(4,actionid.length),
						          "nodeId,"+id.substring(0,id.lastIndexOf(",")).replace(/,/g,"#")+"",
						          extendNodeId,extendClick,levelDown);
					}else{
						loadTree(id.substring(0,id.lastIndexOf(","))+",cset",
						          actionid.substring(4,actionid.length),
						          "nodeId,"+id.substring(0,id.lastIndexOf(",")).replace(/,/g,"#")+""); 
					}              
				}
				//节点图片更换
				ctp(id.substring(0,id.lastIndexOf(",")) + "icon,u");
			} else {
				hiddenChild(id.substring(0,id.lastIndexOf(",")));
				ctp(id.substring(0,id.lastIndexOf(",")) + "icon,s");
			}
			treeLayOut(id.split(",")[0]+",-1");
		}
		if(event){
			event.cancelBubble = true;
		}
	}
};

/**树的图片切换*/
var ctp = function(divid){
	if(divid.substring(divid.length-1,divid.length) == "s"){
		$(divid.substring(0,divid.length-1)+"s").style.visibility = "Hidden";
		$(divid.substring(0,divid.length-1)+"u").style.visibility = "inherit";
	}else{
		$(divid.substring(0,divid.length-1)+"s").style.visibility = "inherit";
		$(divid.substring(0,divid.length-1)+"u").style.visibility = "Hidden";
	}
};

/**虚根的图片切换*/
var vrp = function(divid){
	if($(divid+",cts").style.visibility == "hidden"){
		$(divid+",cts").style.visibility = "inherit";
		$(divid+",ctu").style.visibility = "hidden";
		$(divid+",cset").style.visibility = "inherit";
		$(divid+",cset").style.position = "static";
		
	}else{
		$(divid+",cts").style.visibility = "hidden";
		$(divid+",ctu").style.visibility = "inherit";
		$(divid+",cset").style.visibility = "hidden";
		$(divid+",cset").style.position = "absolute";
	}
};

/**显示树的孩子*/
var showChild = function(id) {
	//判断树的ID是否包含id,如果包含显示结点
//	$(id + ",cset").style.visibility = "inherit";
//	$(id + ",cset").style.position = "fixed";
	$(id + ",cset").style.display = "block";

};
/**隐藏树的孩子*/
var hiddenChild = function(id) {
	//判断树的ID是否包含id,如果包含隐藏结点
//	$(id + ",cset").style.visibility = "hidden";
//	$(id + ",cset").style.position = "absolute";
	$(id + ",cset").style.display = "none";

};
/**判断是否已经装载了子节点*/
var isHave = function(id){
	if($(id + ",cset")!==null && $(id + ",cset").innerHTML!==null && $(id + ",cset").innerHTML!=="" && $(id + ",cset").getElementsByTagName("DIV").length>0){
		return true;
	}
	return false;
};
/**展开指定节点及其父节点*/
var show = function(oid) {
	//要操作的父id数组getParent(oid, ",", "cset");
	for (i = getParent(oid, ",", "cset").length - 1; i >= 0; i-=1) {
		tk(getParent(oid, ",", "cset")[i].split(",")[0] + ",c");
	}
};
/**取对象的父对象信息
  oid:当前对象id
  separator：当前对象父对象匹配时的分割符
  sufic:父对象id的后缀分割符，用separator将后缀与整个id分割开
  如父id:t12,cset  separator:,  sufic: cset
  返回父id的字符串数组
*/
var getParent = function(oid, separator, sufic) {

	//当前对象$(oid)
	//父对象id  $(oid).parentNode
	var parentIds = "";
	while ($(oid).parentNode !== null) {
		$(oid).parentNode = $(oid).parentNode.parentNode;
		if ($(oid).parentNode !== null) {
			if ($(oid).parentNode !== null && $(oid).parentNode.id !== "undefind" && $(oid).parentNode.id !== "" && $(oid).parentNode.id !== null && $(oid).parentNode.id.split(separator).length > 1 && $(oid).parentNode.id.split(separator)[1] == sufic) {
				parentIds = parentIds + parentO.id + "#";
			}
		}
	}
	if (parentIds.lastIndexOf("#") != -1) {
		parentIds = parentIds.substring(0, parentIds.lastIndexOf("#"));
	}
	return parentIds.split("#");
};
/**取对象的子对象信息
  oid:当前对象id
  separator：当前对象子对象匹配时的分割符
  sufic:子对象id的后缀分割符，用separator将后缀与整个id分割开
  type:子对象类型过滤条件 如 DIV 只选择类型为DIV的子对象
  如子id:t12,cset  separator:,  sufic:cset
  返回子id的字符串数组
*/
var getChild = function(oid, separator, sufic, type) {
	var childIds = "";
	for (i = 0; i < $(oid).getElementsByTagName("DIV").length; i+=1) {
		var node = $(oid).getElementsByTagName("DIV")[i];
		if ($(oid).getElementsByTagName("DIV")[i] !== null && $(oid).getElementsByTagName("DIV")[i].id !== "undefind" && $(oid).getElementsByTagName("DIV")[i].id !== "" && node.id !== null && $(oid).getElementsByTagName("DIV")[i].id.split(separator).length > 1 && $(oid).getElementsByTagName("DIV")[i].id.split(separator)[1] == sufic) {
			childIds = childIds + node.id + "#";
		}
	}
	if (childIds.lastIndexOf("#") != -1) {
		childIds = childIds.substring(0, childIds.lastIndexOf("#"));
	}
	return childIds.split("#");
};

/**显示右键菜单公共调用函数
   根据传入的参数信息，查找右键菜单的配置信息，生成右键选择函数
 */
var showRM = function(node,nodeType){
	if(node.id.split(",").length>2){
		if($(node.id.split(',')[0]+nodeType)!==null &&
		          $(node.id.split(',')[0]+nodeType)!==""){
			showRightMenu($(node.id.split(',')[0]+nodeType).value,node.id);
		}
	}
};

/**显示右键菜单（
     右键菜单的参数提交方式:
      右键菜单的参数来自于两个容器,
        一个是右键菜单操作的树的节点的容器，此容器主要提供树节点的信息
        一个是右键菜单容器，此容器主要用于自定义参数的传递(只限新树)
    ）
  divid : 当前节点的右键菜单容器id
  treeId : 当前节点的详细id
*/
var showRightMenu = function(divid,treeId) {
	//rmopt.value 右键的操作节点容器
	/**将定义的右键菜单放到公共的右键菜单弹出窗口中显示*/
	$("rmpop").innerHTML=$(divid).innerHTML+
	              "<input type=\'hidden\' name=\'rmopt\' value='"+treeId+"'>"; 
	//右键菜单的节点中分拆节点的容器id 
    $(treeId).innerHTML=$(treeId).innerHTML+
    			  "<input type=\'hidden\' name=\'h,rmcid\' value='"+treeId.split(",")[0]+","+treeId.split(",")[1]+",cset'>";
    $(treeId).innerHTML=setPm(treeId,"h,.nodeId",treeId.split(",")[1]);	
    $(treeId).innerHTML=setPm(treeId,"h,.nodeRealId",treeId.split(",")[7]);
    $(treeId).innerHTML=setPm(treeId,"h,.nodeLevel",treeId.split(",")[4]);
    $(treeId).innerHTML=setPm(treeId,"h,.treeIndex",treeId.split(",")[2]);
    $(treeId).innerHTML=setPm(treeId,"h,.node_type",treeId.split(",")[2]);
    $(treeId).innerHTML=setPm(treeId,"h,.pcid",treeId.split(",")[0].substring(0,4));
    $(treeId).innerHTML=setPm(treeId,"h,.aid",treeId.split(",")[0].substring(4,treeId.split(",")[0].length));
    		  
    if(treeId.split(",").length>0){
    	$(treeId.split(",")[0]+"nodehi").value = divid;
    }
    //设置可见
    $("rmpop").style.visibility = "visible";
    $("rmpop").style.position="absolute";
    //设计位置
    mouseFollow("rmpop");
    changeBg($(treeId)); 
    document.onclick = function(){hiddenRm('');};
};
/**显示右键菜单公共调用函数
   根据传入的参数信息，查找右键菜单的配置信息，生成右键选择函数
 */
var showRMNew = function(node,nodeType){
	if(node.id.split(",").length>2){
		if($(node.id.split(',')[0]+nodeType)!==null &&
		          $(node.id.split(',')[0]+nodeType)!==""){
		    if(setRightItem(node,nodeType)==1){
				showRightMenuNew($(node.id.split(',')[0]+nodeType).value,node.id);
			}
		}
	}
};

/**
 * 设置右键菜单项
 * node:当前节点容器id,
 * nodeType:treeIndex+operatorType
 */
var setRightItem = function(node,nodeType){
  var rmShowSet;//右键菜单项是否显示字符串(operatorType1:itemName1:nodedesc1,operatorType2:itemName2:nodedesc2)
  var rmName = $(node.id.split(',')[0]+nodeType).value;//此节点对应的右键菜单
  var rmItems = $(node.id.split(',')[0]+nodeType+'it').value;//此节点对应的右键菜单菜单项名称集合
  //取设置显示的节点操作类型
  if($(node.id.split(',')[0]+"rm")!==null &&
		          $(node.id.split(',')[0]+"rm")!==""){
	rmShowSet = $(node.id.split(',')[0]+"rm").value;
  }
  //查找rmShowSet中的operatorType等于nodeType的项,判断nodedesc是否为空,为空则责直接显示,不为空,判断当前接地的nodedesc是否和
  //rmShowSet中的nodedesc相等,不相等则不显现。
  return setRM(rmName,nodeType,node.id.split(',')[9],rmShowSet);
};

var setRM = function(rmName,nodeType,nodedesc,rmShowSet){
	var arrRmShowSet = rmShowSet.split(",");
	var arrItem; 
	$(rmName+"c").innerHTML="";
	var haveItem=0;
	for(var i=0;i<arrRmShowSet.length;){
		arrItem = arrRmShowSet[i].split(":");
		if(nodeType==arrItem[0]){
			if(arrItem[2]===null || arrItem[2]==="" || arrItem[2]==="null" || nodedesc===arrItem[2]+"text"){
				$(rmName+"c").innerHTML = $(rmName+"c").innerHTML + $(arrItem[1]).innerHTML;
				haveItem = 1;
			}
		}
		i=i+1;
	}
	return haveItem;
};

/**显示右键菜单（
     右键菜单的参数提交方式:
      右键菜单的参数来自于两个容器,
        一个是右键菜单操作的树的节点的容器，此容器主要提供树节点的信息
        一个是右键菜单容器，此容器主要用于自定义参数的传递(只限新树)
    ）
  divid : 当前节点的右键菜单容器id
  treeId : 当前节点的详细id
*/
var showRightMenuNew = function(divid,treeId) {
	//rmopt.value 右键的操作节点容器
	/**将定义的右键菜单放到公共的右键菜单弹出窗口中显示*/
	$("rmpop").innerHTML=$(divid).innerHTML+
	              "<input type=\'hidden\' name=\'rmopt\' value='"+treeId+"'>"; 
	//右键菜单的节点中分拆节点的容器id 
    $(treeId).innerHTML=$(treeId).innerHTML+
    			  "<input type=\'hidden\' name=\'h,rmcid\' value='"+treeId.split(",")[0]+","+treeId.split(",")[1]+",cset'>";
    $(treeId).innerHTML=setPm(treeId,"h,.nodeId",treeId.split(",")[1]);	
    $(treeId).innerHTML=setPm(treeId,"h,.nodeRealId",treeId.split(",")[7]);
    $(treeId).innerHTML=setPm(treeId,"h,.nodeLevel",treeId.split(",")[4]);
    $(treeId).innerHTML=setPm(treeId,"h,.treeIndex",treeId.split(",")[2]);
    $(treeId).innerHTML=setPm(treeId,"h,.node_type",treeId.split(",")[2]);
    $(treeId).innerHTML=setPm(treeId,"h,.pcid",treeId.split(",")[0].substring(0,4));
    $(treeId).innerHTML=setPm(treeId,"h,.aid",treeId.split(",")[0].substring(4,treeId.split(",")[0].length));
    $(treeId).innerHTML=setPm(treeId,"h,.nodeCId",treeId.substring(0,treeId.length-4));	
    		  
    if(treeId.split(",").length>0){
    	$(treeId.split(",")[0]+"nodehi").value = divid;
    }
    //设置可见
    $("rmpop").style.visibility = "visible";
    $("rmpop").style.position="absolute";
    //设计位置
    $("rmpop").style.left = getMousePos().x;
    $("rmpop").style.top = getMousePos().y; 
    changeBg($(treeId)); 
    document.onclick = function(){hiddenRm('');};
};
/**隐藏右键菜单 rmid:隐藏的容器id*/
var hiddenRm = function(rmid){	
	$("rmpop").style.visibility = "hidden";
	if(tbgCurrent!==-1 && $(tbgCurrent)!=="" && $(tbgCurrent)!==null){
		$(tbgCurrent).style.background="#ffffff";
	}
	document.onclick = function(){};
};
/**树的OnMouse处理事件-无左键节点  node:树的节点id*/
var onNode = function(node){
	node.style.fontWeight="600";
	node.style.cursor="hand";
	if(!node.onmouseout){
		node.onmouseout = function(){
			node.style.fontWeight="normal";
		};
	}
};
/**树的OnMouse处理事件-左键节点  node:树的节点id*/
var onNodeL = function(node){
	node.style.fontWeight="600";
	node.style.cursor="hand";
	node.style.textDecoration="underline";
	if(!node.onmouseout){
		node.onmouseout = function(){
			node.style.fontWeight="normal";
			node.style.textDecoration="none";
		};
	}
};
/**装载树 
   cId:树的容器id ,
   actionId:树的操作id, 
   rid: treeNodeId,treeNaodIdValue 树的节点id,以逗号分隔的键值组
   extendNodeId:需要展开的节点id,
   leve
 */
var loadTree = function(cId,actionId,rid,extendNodeId,extendClick,levelDown){
	
	if(rid===undefined){
		rid = "-1";
	}
	//树的左键 目标容器id和actionId、树是否显示右键，是否显示复选框
	var other = $(cId.split(",")[0]+cId.split(",")[2]).value;
	other = other.split(",");
	//展开节点的Id参数
	var enodeId="";
	if(extendNodeId){
		enodeId = extendNodeId;
	}else{
		if($(cId.split(",")[0]+"etId")){
			enodeId = $(cId.split(",")[0]+"etId").value;
		}
	}
	var enodeLevel="";
	if($(cId.split(",")[0]+"etLv")){
		enodeLevel = $(cId.split(",")[0]+"etLv").value;
	}
	var enodeClick="";
	if(extendClick){
		enodeClick = extendClick;
	}else if($(cId.split(",")[0]+"etck")){
		enodeClick = $(cId.split(",")[0]+"etck").value;
	}
	//自定义参数
	var customerParam="";
	if($(cId.split(",")[0]+"cuPam")){
		customerParam = $(cId.split(",")[0]+"cuPam").value;
	}
	//是否根据operator过滤
	var isFilterByOperator="";
	if($(cId.split(",")[0]+"isFiByOpId")){
		isFilterByOperator = $(cId.split(",")[0]+"isFiByOpId").value;
	}
	//自定义key和value的参数
	var cust = "noset,''";
	if($(cId.split(",")[0]+"paKs") 
	     && $(cId.split(",")[0]+$(cId.split(",")[0]+"paKs").value)){
		cust = $(cId.split(",")[0]+"paKs").value+","+$(cId.split(",")[0]+$(cId.split(",")[0]+"paKs").value).value;
	}
	//是否显示加减号
	var showAdd="";
	if($(cId.split(",")[0]+"add")){
		showAdd = $(cId.split(",")[0]+"add").value;
	}
	//向下展开几级
	var ld="";
	if(levelDown){
		ld = levelDown;
	}
	sp(cId,actionId,cId,1,0,rid,
	   "tId,"+other[0],
	   "aId,"+other[1],
	   "srm,"+other[2],
	   "sck,"+other[3],
	   "bmType,"+other[5],
	   "extendId,"+enodeId,
	   "extendNodeLevel,"+enodeLevel,
	   "extendClick,"+enodeClick,
	   ".customerParam,"+customerParam,
	   "isFilterByOperator,"+isFilterByOperator,
	   "dcParams,"+other[7],
	   cust,
	   ".filterOperatorId,"+other[10],
	   "showAdd,"+showAdd,
	   "rlevelDown,"+ld);
};
/**树的左键事件*/
var tl = function(cid,aid,rid,tid,cotherId){
	changeBg($(cid));
	//如果其他容器不为空，则提交其他容器的数据
	if(cotherId && $(cotherId)){
		cid = cotherId;
		//设置树的rid到其他容器中
		if($(cotherId+"r")){
			$(cotherId+"r").value=rid;
		}
	}
	m(cid,aid,rid,tid);
};
/**树的左键事件*/
var tln = function(cid,aid,rid,tid,cotherId){
	//changeBg($(cid));
	
	m(cid,aid,rid,tid,cotherId);
};
var tbgCurrent = "-1"; 
/**点击节点后更换背景色*/
var changeBg = function(node){
	if(tbgCurrent!==-1 && $(tbgCurrent)!=="" && $(tbgCurrent)!==null){
		$(tbgCurrent).style.background="#ffffff";
	}
	if(node!==null){
		node.style.background="#BFDBFF";
		tbgCurrent = node.id;
	}
};
var changeBg1 = function(node){
	if(node!==null){
		node.style.background="#BFDBFF";
		tbgCurrent = node.id;
	}
	if(!node.onmouseout){
		node.onmouseout = function(){node.style.background="#ffffff";};
	}
};
/**树的维护 otherContainer:除cid外，其他需要提交数据的容器*/
var treeS = function(actionId,otherContainer){
	//设置隐藏
    hiddenRm();
	//p($("rmopt").value,actionId,1,1);
	pr($("rmopt").value,actionId,1,otherContainer);
};
var treep = function(actionId,poplevel){
	//设置隐藏
    hiddenRm();
	p($("rmopt").value,actionId,poplevel,1);
};

/**菜单*/
var currentSid="-1";
var sheekShow = function(obj){
	if(obj && obj.id.split(",").length>2){
		if(currentSid!=-1 && currentSid.split(",").length>2){
			$(currentSid.split(",")[0]+","+currentSid.split(",")[1]+",cset").style.display="none";
		}
		if($(obj.id.split(",")[0]+","+obj.id.split(",")[1]+",cset")){
			$(obj.id.split(",")[0]+","+obj.id.split(",")[1]+",cset").style.display="block";
		}
		currentSid = obj.id;
	}
};

/** menu onmouseover事件 */
var mo=function(x,cssId){
	x.className='sleekmo';
	if(!x.onmouseout){
		x.onmouseout=function(){this.className=cssId;};
	}
};
/**整棵树刷新，并展开节点,老树使用
   只有单棵树使用时才能有增删改，才会有刷新，所以nodeType一定是可以由Dc指定的
   pcid 调用树vc的容器id
   actionId 树的vc显示行为id
   extendNodeId 需要展开的节点id
   extendNodeLevel 需要展开的节点级别
   nodeType 需要展开的节点的类型
   nodeTypeAll 树中所有的节点类型 以"_"分割
   otherParam 其他参数"paramName,paramValue"
*/
var treeWholeRefresh=function(pcid,
                             actionId,
                             extendNodeId,
                             extendNodeLevel,
                             nodeType,
                             nodeTypeAll,
                             otherParam){
	//树的左键 目标容器id和actionId、树是否显示右键，是否显示复选框
	var other = $(pcid+actionId+nodeType).value;
	other = other.split(",");
	//自定义参数
	var customerParam="";
	if($(pcid+actionId+"cuPam")){
		customerParam = $(pcid+actionId+"cuPam").value;
	}
	//自定义key和value的参数
	var cust = "noset,''";
	if($(pcid+actionId+"paKs") && $(pcid+actionId+$(pcid+actionId+"paKs").value)){
		cust = $(pcid+actionId+"paKs").value+","+$(pcid+actionId+$(pcid+actionId+"paKs").value).value;
	}
	//dc过滤器
	var filter = "filter,"+nodeType+":"+other[4];
	if(!nodeTypeAll || nodeTypeAll===null || nodeTypeAll===""){
	  if(other.length>6){
	  	filter = "filter,"+nodeType+":"+other[4]+":"+other[6];
	  }
	  if(otherParam){
		sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   "callback,"+nodeType+":"+other[0]+":"+other[1]+":"+other[5],
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendNodeLevel,"+extendNodeLevel,
		   filter,
		   "bmType,"+other[5],
		   "refresh,Y",
		   ".customerParam,"+customerParam,
		   "dcParams,"+other[7],
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   cust,
		   ".filterOperatorId,"+other[10],
		   otherParam);
	   }else{
	   		sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   "callback,"+nodeType+":"+other[0]+":"+other[1]+":"+other[5],
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendNodeLevel,"+extendNodeLevel,
		   filter,
		   "bmType,"+other[5],
		   "refresh,Y",
		   ".customerParam,"+customerParam,
		   "dcParams,"+other[7],
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   cust,
		   ".filterOperatorId,"+other[10]);
	   }
	 }else{
	    if(otherParam){
		   sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   getCallBack(pcid,actionId,nodeTypeAll),
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendNodeLevel,"+extendNodeLevel,
		   getFilter(pcid,actionId,nodeTypeAll),
		   "bmType,"+other[5],
		   "refresh,Y",
		   "refreshVc,Y",
		   ".customerParam,"+customerParam,
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   cust,
		   ".filterOperatorId,"+other[10],
		   otherParam);
		}else{
			 sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   getCallBack(pcid,actionId,nodeTypeAll),
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendNodeLevel,"+extendNodeLevel,
		   getFilter(pcid,actionId,nodeTypeAll),
		   "bmType,"+other[5],
		   "refresh,Y",
		   "refreshVc,Y",
		   ".customerParam,"+customerParam,
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   cust,
		   ".filterOperatorId,"+other[10]);
		}
    }
};
/**整棵树刷新，并展开节点,新树使用
   只有单棵树使用时才能有增删改，才会有刷新，所以nodeType一定是可以由Dc指定的
   pcid 调用树vc的容器id
   actionId 树的vc显示行为id
   extendNodeId 需要展开的节点id
   extendClick 是否点击需要展开的节点
   treeIndex 需要展开的树编号
   otherParam 其他参数"paramName,paramValue"
*/
var treeWholeRefreshNew=function(pcid,
                                 actionId,
                                 extendNodeId,
                                 extendClick,
                                 treeIndex,
                                 otherParam){
    //检查参数
    if(!(pcid)){throw new Error("树刷新失败: 需要pcid!");}
    if(!(actionId)){throw new Error("树刷新失败: 需要actionId!");}
    if(!(treeIndex)){throw new Error("树刷新失败: 需要treeIndex!");}
	//树的左键 目标容器id和actionId、树是否显示右键，是否显示复选框
	var other = $(pcid+actionId+treeIndex).value;
	other = other.split(",");
	//自定义参数
	var customerParam="";
	if($(pcid+actionId+"cuPam")){
		customerParam = $(pcid+actionId+"cuPam").value;
	}
	//自定义key和value的参数
	var cust = "noset,''";
	if($(pcid+actionId+"paKs") && $(pcid+actionId+$(pcid+actionId+"paKs").value)){
		cust = $(pcid+actionId+"paKs").value+","+$(pcid+actionId+$(pcid+actionId+"paKs").value).value;
	}
	//dc过滤器
	var filter = "filter,"+treeIndex+":"+other[4];
	if(otherParam){
		   sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   getCallBack(pcid,actionId,$(pcid+actionId+"idx").value),
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendClick,"+extendClick,
		   getFilter(pcid,actionId,$(pcid+actionId+"idx").value),
		   "bmType,"+other[5],
		   "refresh,Y",
		   "refreshVc,Y",
		   ".customerParam,"+customerParam,
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   "virRootExt,"+$(pcid+actionId+"vNExt").value,
		   cust,
		   ".filterOperatorId,"+other[10],
		   "tIndex,"+treeIndex,
		   "hdp,"+$("ahd"+pcid+actionId).value,
		   otherParam);
	}else{
		sp(pcid+actionId+",-1",
		   actionId,
		   pcid+actionId+",-1",
		   1,
		   0,
		   "pcid,"+pcid,
		   getCallBack(pcid,actionId,$(pcid+actionId+"idx").value),
		   "srm,"+other[2],
		   "sck,"+other[3],
		   "extendId,"+extendNodeId,
		   "extendClick,"+extendClick,
		   getFilter(pcid,actionId,$(pcid+actionId+"idx").value),
		   "bmType,"+other[5],
		   "refresh,Y",
		   "refreshVc,Y",
		   ".customerParam,"+customerParam,
		   "virRoot,"+$(pcid+actionId+"vN").value,
		   "virRootExt,"+$(pcid+actionId+"vNExt").value,
		   cust,
		   "tIndex,"+treeIndex,
		   ".filterOperatorId,"+other[10],
		   "hdp,"+$("ahd"+pcid+actionId).value);
	}
};
/**树刷新时的回调参数*/
var getCallBack=function(pcid,actionId,nodeTypeOther){
    var other;
    var callback = "callback,";
	nodeTypeOther = nodeTypeOther.split("_");
	for(var i=0;i<nodeTypeOther.length;){
	    if($(pcid+actionId+nodeTypeOther[i])){
			other = $(pcid+actionId+nodeTypeOther[i]).value.split(",");
			if(i>0){
			   callback = callback+"~";
			}
			callback = callback+nodeTypeOther[i]+":"+other[0]+":"+other[1]+":"+other[5]+":"+other[7]+":"+other[8]+":"+other[9];
		}
		i=i+1;
	}
	return callback;
};
/**树刷新时的过滤器参数*/
var getFilter=function(pcid,actionId,nodeTypeOther){
	var other;
    var callback = "filter,";
	nodeTypeOther = nodeTypeOther.split("_");
	for(var i=0;i<nodeTypeOther.length;){
		if($(pcid+actionId+nodeTypeOther[i])){
			other = $(pcid+actionId+nodeTypeOther[i]).value.split(",");
			if(i>0){
			   callback = callback+"~";
			}
			if(other.length>6){
				callback = callback+nodeTypeOther[i]+":"+other[4]+":"+other[6];
			}else{
				callback = callback+nodeTypeOther[i]+":"+other[4]
			}
		}
		i=i+1;
	}
	return callback;
};
/**树的布局，展开节点之后调用*/
var treeLayOut=function(rootId){
	//alert(rootId);
};

/**判断源容器中是否有隐藏的表单对象，有则返回innerHTML，没有，返回innerHTML+新表单 */
/**srcCId:容器id  paramName:增加的参数名  paramValue:增加的参数值*/
var setPm =function(srcCId,paramName,paramValue){
	//判断源容器是否存在
	if($(srcCId)){
		//目标容器中是否有此参数
		if($(srcCId).getElementsByTagName("input")){
			 if($(srcCId).getElementsByTagName("input").length>0){
			 	for (i = 0; i < $(srcCId).getElementsByTagName("input").length; i+=1) {
					var node = $(srcCId).getElementsByTagName("input")[i];
					if ($(srcCId).getElementsByTagName("input")[i] !== null 
						&& $(srcCId).getElementsByTagName("input")[i].id !== "undefind" 
						&& $(srcCId).getElementsByTagName("input")[i].id == paramName ) {
							return $(srcCId).innerHTML;
					}
			    }
			    return $(srcCId).innerHTML+
    			        "<input type=\'hidden\' id=\'"+paramName+"\' name=\'"+paramName+"\' value='"+paramValue+"'>";
		     }else{
			    return $(srcCId).innerHTML+
    			        "<input type=\'hidden\' id=\'"+paramName+"\' name=\'"+paramName+"\' value='"+paramValue+"'>";	
		     }
		}
	}
};
/**
  树的添加刷新
   参数:
   nodeCId 添加节点时右键点击节点的容器id
   actionId 树vc的行为id
   nodeId 新添加的节点id   
 */
var addRf = function(nodeCId,actionId,nodeId){
	//判断nodeCId是否有子,如果没有查找其父节点
	var levelDown = "1";
	if(!haveChild(nodeCId)){
	    if(isRoot(nodeCId)){
	       treeWholeRefreshNew(nodeCId.split(",")[0].substring(0,4),actionId,nodeId,"1",nodeCId.split(",")[2]);
	       return;
	    }else{
			//无子需要展开爷爷节点,查找nodeCId的父亲
			nodeCId = getPCid(nodeCId);
			levelDown = "2"; 
		}
	}
	//设置nodeCId+",cset"为空
	$(nodeCId+",cset").innerHTML="";
	//处理nodeCId所对应的加号和图片
	picDeal(nodeCId);
	//根据节点的级别来判断调用哪个展开
	rftk(nodeCId,nodeId,levelDown);
};
/*
  树的修改刷新
*/
var modifyRf = function(nodeCId,actionId){
	//为避免传中文名称进来,需要从数据库刷新数据,所以这里用和添加类似的展开方式来实现
	var nodeId = nodeCId.split(",")[1];
	if(isRoot(nodeCId)){
	    treeWholeRefreshNew(nodeCId.split(",")[0].substring(0,4),actionId,nodeId,"1",nodeCId.split(",")[2]);
	    return;
	}else{
		nodeCId = getPCid(nodeCId);
	}
	addRf(nodeCId,actionId,nodeId);
};
/*
  树的删除刷新
*/
var deleteRf = function(nodeCId,actionId){
	//查询父亲节点
	nodeCId = nodeCId = getPCid(nodeCId);
	var nodeId = nodeCId.split(",")[1];
	//判断父id的节点是否是根节点
	if(isRoot(nodeCId)){
	    treeWholeRefreshNew(nodeCId.split(",")[0].substring(0,4),actionId,nodeId,"1",nodeCId.split(",")[2]);
	    return;
	}else{
		nodeCId = getPCid(nodeCId);
	}
	addRf(nodeCId,actionId,nodeId);
};
/**刷新前图片处理*/
var picDeal = function(nodeCId){
	//判断加号是否存在(加减号总数成对出现的,都有或都没有)
	if($(nodeCId+",c")){
		$(nodeCId+",c").style.visibility = "inherit";
		$(nodeCId+",e").style.visibility = "hidden";
	}
	//判断图标是否存在(当前容器一定是有孩子的,所以图片一定是成对出现,都有或都没有)
	if($(nodeCId+"icon,u")){
		$(nodeCId+"icon,u").style.visibility = "inherit";
		$(nodeCId+"icon,s").style.visibility = "hidden";
	}
};
/**根据节点是否有加减号判断调用哪个展开*/
var rftk = function(nodeCId,nodeId,levelDown){
	if($(nodeCId+",e")){
		tk(nodeCId+",e",nodeCId.split(",")[0],nodeId,"1",levelDown);
	}else{
		tkr(nodeCId+",s",nodeCId.split(",")[0],nodeId,"1",levelDown);
	}
};
/**判断此容器节点是否有子*/
var haveChild = function(nodeCId){
	if($(nodeCId+",e") || $(nodeCId+"icon,s")){
		return true;
	}else{
		return false;
	}
};
/**取nodeCid的父容器id,不带"cset的"*/
var getPCid = function(nodeCid) {
	//当前对象$(oid)
	//父对象id  $(oid).parentNode
	var parentId = "";
	if($(nodeCid).parentNode !== null) {
		parentId = $(nodeCid).parentNode.id;
	}
	if (parentId.lastIndexOf(",cset") != -1) {
		parentId = parentId.substring(0, parentId.lastIndexOf(",cset"));
	}
	return parentId;
};
/**判断节点是否是根节点*/
var isRoot = function(nodeCid){
	//如果级别是1则是根节点
	if(nodeCid.split(",")[4]=="1"){
		return true;
	}else{
		return false;
	}
};
